package com.zql.LeetCode;

/**
 * 26. 删除有序数组中的重复项
 * Created By ShuHua on 2021/8/21.
 */
public class RemoveDuplicates_26 {

    public int removeDuplicates(int[] nums) {
        if(nums==null||nums.length==0) return 0;
        if(nums.length==1)return 1;

        int current=0;
        for(int i =0;i<nums.length-1;i++){
            if(nums[i]!=nums[i+1]){
                nums[++current] = nums[i+1];
            }
        }
        return current+1;
    }
}
